/**
 * 
 */
package com.sci.web.action.register;

import javax.annotation.Resource;

import com.sci.web.action.util.BaseAction;
import com.sci.web.bean.Enterprise_Base;
import com.sci.web.bean.UserRegister;
import com.sci.web.dao.UserRegisterDao;

/**
 * @author BaiFuyou
 * @date: Sep 29, 2011 3:08:04 PM
 * 
 * 天加一个新的企业用户
 */
public class AddNewEnterpriseAction extends BaseAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5118015360450155333L;
	@Resource
	private UserRegisterDao registerdao;
	private String user_name;
	private String user_pwd;
	private String user_mail;
	private String enterprise_address;
	private String enterprise_name;
	private int enterprise_city;
	private String enterprise_post_code;
	private String enterprise_corporate_code;
	private String enterprise_corporateRepresentative;
	private String enterprise_telephone;
	private String enterprise_person_incharge;
	private String enterprise_phone_incharge;
	private String enterprise_business_field;
	private String enterprise_major_business;
	private int enterprise_eco_type;
	private int enterprise_org_type;
	private String enterprise_largest_sharehoder;
	private float enterprise_largest_share;
	private int enterprise_listed_type;
	private int enterprise_industry_code;
	private int enterprise_credit_degree;
	private int enterprise_science_type;
	private int enterprise_staff_count;
	private int enterprise_staff_collegedegree_count;
	private int enterprise_research_staff_count;
	private int enterprise_senior_technician_count;
	private int enterprise_field_closeness;

	/**
	 * @return the user_name
	 */
	public String getUser_name() {
		return user_name;
	}

	/**
	 * @param user_name
	 *            the user_name to set
	 */
	public void setUser_name(String user_name) {
		this.user_name = user_name;
	}

	/**
	 * @return the user_pwd
	 */
	public String getUser_pwd() {
		return user_pwd;
	}

	/**
	 * @param user_pwd
	 *            the user_pwd to set
	 */
	public void setUser_pwd(String user_pwd) {
		this.user_pwd = user_pwd;
	}

	/**
	 * @return the enterprise_city
	 */
	public int getEnterprise_city() {
		return enterprise_city;
	}

	/**
	 * @param enterprise_city
	 *            the enterprise_city to set
	 */
	public void setEnterprise_city(int enterprise_city) {
		this.enterprise_city = enterprise_city;
	}

	/**
	 * @return the enterprise_post_code
	 */
	public String getEnterprise_post_code() {
		return enterprise_post_code;
	}

	/**
	 * @param enterprise_post_code
	 *            the enterprise_post_code to set
	 */
	public void setEnterprise_post_code(String enterprise_post_code) {
		this.enterprise_post_code = enterprise_post_code;
	}

	/**
	 * @return the enterprise_corporate_code
	 */
	public String getEnterprise_corporate_code() {
		return enterprise_corporate_code;
	}

	/**
	 * @param enterprise_corporate_code
	 *            the enterprise_corporate_code to set
	 */
	public void setEnterprise_corporate_code(String enterprise_corporate_code) {
		this.enterprise_corporate_code = enterprise_corporate_code;
	}

	/**
	 * @return the enterprise_corporateRepresentative
	 */
	public String getEnterprise_corporateRepresentative() {
		return enterprise_corporateRepresentative;
	}

	/**
	 * @param enterprise_corporateRepresentative
	 *            the enterprise_corporateRepresentative to set
	 */
	public void setEnterprise_corporateRepresentative(String enterprise_corporateRepresentative) {
		this.enterprise_corporateRepresentative = enterprise_corporateRepresentative;
	}

	/**
	 * @return the enterprise_telephone
	 */
	public String getEnterprise_telephone() {
		return enterprise_telephone;
	}

	/**
	 * @param enterprise_telephone
	 *            the enterprise_telephone to set
	 */
	public void setEnterprise_telephone(String enterprise_telephone) {
		this.enterprise_telephone = enterprise_telephone;
	}

	/**
	 * @return the enterprise_person_incharge
	 */
	public String getEnterprise_person_incharge() {
		return enterprise_person_incharge;
	}

	/**
	 * @param enterprise_person_incharge
	 *            the enterprise_person_incharge to set
	 */
	public void setEnterprise_person_incharge(String enterprise_person_incharge) {
		this.enterprise_person_incharge = enterprise_person_incharge;
	}

	/**
	 * @return the enterprise_phone_incharge
	 */
	public String getEnterprise_phone_incharge() {
		return enterprise_phone_incharge;
	}

	/**
	 * @param enterprise_phone_incharge
	 *            the enterprise_phone_incharge to set
	 */
	public void setEnterprise_phone_incharge(String enterprise_phone_incharge) {
		this.enterprise_phone_incharge = enterprise_phone_incharge;
	}

	/**
	 * @return the enterprise_business_field
	 */
	public String getEnterprise_business_field() {
		return enterprise_business_field;
	}

	/**
	 * @param enterprise_business_field
	 *            the enterprise_business_field to set
	 */
	public void setEnterprise_business_field(String enterprise_business_field) {
		this.enterprise_business_field = enterprise_business_field;
	}

	/**
	 * @return the enterprise_major_business
	 */
	public String getEnterprise_major_business() {
		return enterprise_major_business;
	}

	/**
	 * @param enterprise_major_business
	 *            the enterprise_major_business to set
	 */
	public void setEnterprise_major_business(String enterprise_major_business) {
		this.enterprise_major_business = enterprise_major_business;
	}

	/**
	 * @return the enterprise_eco_type
	 */
	public int getEnterprise_eco_type() {
		return enterprise_eco_type;
	}

	/**
	 * @param enterprise_eco_type
	 *            the enterprise_eco_type to set
	 */
	public void setEnterprise_eco_type(int enterprise_eco_type) {
		this.enterprise_eco_type = enterprise_eco_type;
	}

	/**
	 * @return the enterprise_org_type
	 */
	public int getEnterprise_org_type() {
		return enterprise_org_type;
	}

	/**
	 * @param enterprise_org_type
	 *            the enterprise_org_type to set
	 */
	public void setEnterprise_org_type(int enterprise_org_type) {
		this.enterprise_org_type = enterprise_org_type;
	}

	/**
	 * @return the enterprise_largest_sharehoder
	 */
	public String getEnterprise_largest_sharehoder() {
		return enterprise_largest_sharehoder;
	}

	/**
	 * @param enterprise_largest_sharehoder
	 *            the enterprise_largest_sharehoder to set
	 */
	public void setEnterprise_largest_sharehoder(String enterprise_largest_sharehoder) {
		this.enterprise_largest_sharehoder = enterprise_largest_sharehoder;
	}

	/**
	 * @return the enterprise_largest_share
	 */
	public float getEnterprise_largest_share() {
		return enterprise_largest_share;
	}

	/**
	 * @param enterprise_largest_share
	 *            the enterprise_largest_share to set
	 */
	public void setEnterprise_largest_share(float enterprise_largest_share) {
		this.enterprise_largest_share = enterprise_largest_share;
	}

	/**
	 * @return the enterprise_listed_type
	 */
	public int getEnterprise_listed_type() {
		return enterprise_listed_type;
	}

	/**
	 * @param enterprise_listed_type
	 *            the enterprise_listed_type to set
	 */
	public void setEnterprise_listed_type(int enterprise_listed_type) {
		this.enterprise_listed_type = enterprise_listed_type;
	}

	/**
	 * @return the enterprise_industry_code
	 */
	public int getEnterprise_industry_code() {
		return enterprise_industry_code;
	}

	/**
	 * @param enterprise_industry_code
	 *            the enterprise_industry_code to set
	 */
	public void setEnterprise_industry_code(int enterprise_industry_code) {
		this.enterprise_industry_code = enterprise_industry_code;
	}

	/**
	 * @return the enterprise_credit_degree
	 */
	public int getEnterprise_credit_degree() {
		return enterprise_credit_degree;
	}

	/**
	 * @param enterprise_credit_degree
	 *            the enterprise_credit_degree to set
	 */
	public void setEnterprise_credit_degree(int enterprise_credit_degree) {
		this.enterprise_credit_degree = enterprise_credit_degree;
	}

	/**
	 * @return the enterprise_science_type
	 */
	public int getEnterprise_science_type() {
		return enterprise_science_type;
	}

	/**
	 * @param enterprise_science_type
	 *            the enterprise_science_type to set
	 */
	public void setEnterprise_science_type(int enterprise_science_type) {
		this.enterprise_science_type = enterprise_science_type;
	}

	/**
	 * @return the enterprise_staff_count
	 */
	public int getEnterprise_staff_count() {
		return enterprise_staff_count;
	}

	/**
	 * @param enterprise_staff_count
	 *            the enterprise_staff_count to set
	 */
	public void setEnterprise_staff_count(int enterprise_staff_count) {
		this.enterprise_staff_count = enterprise_staff_count;
	}

	/**
	 * @return the enterprise_staff_collegedegree_count
	 */
	public int getEnterprise_staff_collegedegree_count() {
		return enterprise_staff_collegedegree_count;
	}

	/**
	 * @param enterprise_staff_collegedegree_count
	 *            the enterprise_staff_collegedegree_count to set
	 */
	public void setEnterprise_staff_collegedegree_count(int enterprise_staff_collegedegree_count) {
		this.enterprise_staff_collegedegree_count = enterprise_staff_collegedegree_count;
	}

	/**
	 * @return the enterprise_research_staff_count
	 */
	public int getEnterprise_research_staff_count() {
		return enterprise_research_staff_count;
	}

	/**
	 * @param enterprise_research_staff_count
	 *            the enterprise_research_staff_count to set
	 */
	public void setEnterprise_research_staff_count(int enterprise_research_staff_count) {
		this.enterprise_research_staff_count = enterprise_research_staff_count;
	}

	/**
	 * @return the enterprise_senior_technician_count
	 */
	public int getEnterprise_senior_technician_count() {
		return enterprise_senior_technician_count;
	}

	/**
	 * @param enterprise_senior_technician_count
	 *            the enterprise_senior_technician_count to set
	 */
	public void setEnterprise_senior_technician_count(int enterprise_senior_technician_count) {
		this.enterprise_senior_technician_count = enterprise_senior_technician_count;
	}

	/**
	 * @return the user_mail
	 */
	public String getUser_mail() {
		return user_mail;
	}

	/**
	 * @param user_mail
	 *            the user_mail to set
	 */
	public void setUser_mail(String user_mail) {
		this.user_mail = user_mail;
	}

	/**
	 * @return the enterprise_name
	 */
	public String getEnterprise_name() {
		return enterprise_name;
	}

	/**
	 * @param enterprise_name
	 *            the enterprise_name to set
	 */
	public void setEnterprise_name(String enterprise_name) {
		this.enterprise_name = enterprise_name;
	}

	/**
	 * @return the enterprise_address
	 */
	public String getEnterprise_address() {
		return enterprise_address;
	}

	/**
	 * @param enterprise_address
	 *            the enterprise_address to set
	 */
	public void setEnterprise_address(String enterprise_address) {
		this.enterprise_address = enterprise_address;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		super.setContentType(super.JSON);
		UserRegister ur = new UserRegister();
		ur.setUser_email(user_mail);
		/**
		 * 设置用户时企业用户
		 */
		ur.setUser_is_enterprise(1);
		ur.setUser_name(user_name);
		ur.setUser_pwd(user_pwd);
		ur.setUser_role(4);
		ur.setUser_state(0);
		ur.setUser_city(enterprise_city);
		// //////////////////////////////////////////////
		Enterprise_Base en = new Enterprise_Base();
		en.setEditable(0);
		en.setEnterprise_address(enterprise_address);
		en.setEnterprise_business_field(enterprise_business_field);
		en.setEnterprise_city(enterprise_city);
		en.setEnterprise_corporate_code(enterprise_corporate_code);
		en.setEnterprise_corporateRepresentative(enterprise_corporateRepresentative);
		en.setEnterprise_credit_degree(enterprise_credit_degree);
		/**
		 * [['请选择', '0'], ['AAA', '1'], ['AA', '2'],
							['B', '3'], ['C', '4'], ['无', '5']]
		 */
//		if(enterprise_credit_degree == 1){
//			en.setEnterprise_credit_degree("AAA");
//		}else if(enterprise_credit_degree == 2){
//			en.setEnterprise_credit_degree("AA");
//		}else if(enterprise_credit_degree == 3){
//			en.setEnterprise_credit_degree("B");
//			
//		}else if(enterprise_credit_degree == 4){
//			en.setEnterprise_credit_degree("C");
//			
//		}else if(enterprise_credit_degree == 5){
//			en.setEnterprise_credit_degree("无");
//			
//		}
		// en.setEnterprise_demo_year(enterprise_demo_year)
		en.setEnterprise_eco_type(enterprise_eco_type);
		en.setEnterprise_field_closeness(enterprise_field_closeness);
		/**
		 * ['所有', '0'], ['装备制造业', '1'], ['汽车行业', '2'], ['船舶制造业', '3'], ['医药行业', '4'], ['钢铁行业', '5'], ['电子信息行业', '6'], ['石化行业', '7'], ['纺织产业', '8'],
		 * ['轻工食品行业', '9'], ['有色金属行业', '10'], ['建材行业', '11'], ['光伏等新能源行业', '12']]
		 */
		en.setEnterprise_industry_code(enterprise_industry_code);
//		if (enterprise_industry_code == 1) {
//			en.setEnterprise_industry_code("装备制造业");
//		} else if (enterprise_industry_code == 2) {
//			en.setEnterprise_industry_code("汽车行业");
//		} else if (enterprise_industry_code == 3) {
//			en.setEnterprise_industry_code("船舶制造业");
//		} else if (enterprise_industry_code == 4) {
//			en.setEnterprise_industry_code("医药行业");
//		} else if (enterprise_industry_code == 5) {
//			en.setEnterprise_industry_code("钢铁行业");
//		} else if (enterprise_industry_code == 6) {
//			en.setEnterprise_industry_code("电子信息行业");
//		} else if (enterprise_industry_code == 7) {
//			en.setEnterprise_industry_code("石化行业");
//		} else if (enterprise_industry_code == 8) {
//			en.setEnterprise_industry_code("纺织产业");
//		} else if (enterprise_industry_code == 9) {
//			en.setEnterprise_industry_code("轻工食品行业");
//		}else if (enterprise_industry_code == 10) {
//			en.setEnterprise_industry_code("有色金属行业");
//		}else if (enterprise_industry_code == 11) {
//			en.setEnterprise_industry_code("建材行业");
//		}else if (enterprise_industry_code == 12) {
//			en.setEnterprise_industry_code("光伏等新能源行业");
//		}
		en.setEnterprise_largest_share(enterprise_largest_share);
		en.setEnterprise_largest_sharehoder(enterprise_largest_sharehoder);
		en.setEnterprise_listed_type(enterprise_listed_type);
		en.setEnterprise_major_business(enterprise_major_business);
		en.setEnterprise_name(enterprise_name);
		en.setEnterprise_org_type(enterprise_org_type);
		en.setEnterprise_person_incharge(enterprise_person_incharge);
		en.setEnterprise_phone_incharge(enterprise_phone_incharge);
		/*
		 * 没有改变PIC
		 */
		en.setEnterprise_pic("");
		en.setEnterprise_postcode(enterprise_post_code);
		en.setEnterprise_research_staff_count(enterprise_research_staff_count);
		en.setEnterprise_science_type(enterprise_science_type);
		en.setEnterprise_senior_technician_count(enterprise_senior_technician_count);
		en.setEnterprise_staff_collegedegree_count(enterprise_staff_collegedegree_count);
		en.setEnterprise_staff_count(enterprise_staff_count);
		en.setEnterprise_telephone(enterprise_telephone);
		/*
		 * 没有设置企业的网址地址
		 */
		en.setEnterprise_url("");
		super.setContentType(super.JSON);
		if (registerdao.addNewUserAndEnterpriseBase(ur, en)) {
			outPrint("ok");
		} else {
			outPrint("fail");
		}
		return "json";
	}

	/**
	 * @return the enterprise_field_closeness
	 */
	public int getEnterprise_field_closeness() {
		return enterprise_field_closeness;
	}

	/**
	 * @param enterprise_field_closeness
	 *            the enterprise_field_closeness to set
	 */
	public void setEnterprise_field_closeness(int enterprise_field_closeness) {
		this.enterprise_field_closeness = enterprise_field_closeness;
	}

}
